﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectNocturnalFool
{
    public sealed class DebugMgr
    {
        SpriteFont font;

        public bool active = true;

       private  List<string> debugMessages = new List<string>();

        /// <summary>
        /// Allocate ourselves.
        /// We have a private constructor, so no one else can.
        /// </summary>
        static readonly DebugMgr _instance = new DebugMgr();

        /// <summary>
        /// Access SiteStructure.Instance to get the singleton object.
        /// Then call methods on that instance.
        /// </summary>
        public static DebugMgr Instance
        {
            get { return _instance; }
        }

        public void LoadContent()
        {
            font = TacticsGame.Instance.Content.Load<SpriteFont>("Fonts/menufont");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
            debugMessages.Add("");
        }
        
        public void addDebug(string message, int slot)
        {
            if (slot <= 10 && slot >= 0)
                debugMessages[slot] = message;
            else
                debugMessages[debugMessages.Count - 1] = message;   
        }

        public void Draw()
        {
            if (!active)
                return;
            TacticsGame.Instance.spriteBatch.Begin();
            int height = 0;
            for(int i = 0; i < debugMessages.Count; i++)
            {
                TacticsGame.Instance.spriteBatch.DrawString(font, debugMessages[i], new Vector2(0, height), Color.Black, 0.0f, new Vector2(0, 0), Constants.DebugFontScale, SpriteEffects.None, 0);
                 height += 10;
            }
            TacticsGame.Instance.spriteBatch.End();
        }

    }
}
